package com.lzw.blog.admin.controller;

import com.lzw.blog.admin.model.params.PageParam;
import com.lzw.blog.admin.service.ArticleService;
import com.lzw.blog.admin.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;


    @PostMapping("articleList")
    public Result listArticle(@RequestBody PageParam pageParam){
        return articleService.listArticle(pageParam);
    }

    @GetMapping("delete/{id}")
    public Result deleteArticle(@PathVariable("id") Long id) {
        return articleService.delete(id);
    }

    @GetMapping("totalArticles")
    public Result getNum(){return  articleService.getNums();}

    @GetMapping("latestArticles")
    public Result newArticles() {
        return articleService.newArticles(3);
    }

}
